package com.tqz.rc.spring.cloud;

import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;

import java.net.URI;
import java.util.Map;

/**
 * <p>服务实例
 *
 * @author tianqingzhao
 * @since 2021/9/3 15:50
 */
public class TqzRcServiceInstance implements ServiceInstance {

    /**
     * 实例的服务名称
     */
    private String serviceId;

    /**
     * 实例的ip
     */
    private String host;

    /**
     * 实例的端口号
     */
    private int port;

    /**
     * 是否是安全的协议，安全的为https，否则为http
     */
    private boolean secure;

    /**
     * 元数据
     */
    private Map<String, String> metadata;

    @Override
    public String getServiceId() {
        return serviceId;
    }

    @Override
    public String getHost() {
        return host;
    }

    @Override
    public int getPort() {
        return port;
    }

    @Override
    public boolean isSecure() {
        return secure;
    }

    @Override
    public URI getUri() {
        return DefaultServiceInstance.getUri(this);
    }

    @Override
    public Map<String, String> getMetadata() {
        return metadata;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public void setSecure(boolean secure) {
        this.secure = secure;
    }

    public void setMetadata(Map<String, String> metadata) {
        this.metadata = metadata;
    }
}
